<!-- 分配记录 -->
<template>
  <div>
    <dt-modal-info ref='info' :title='title' :width='60' @close='hide'>
      <dt-grid ref="table" :columns="columns" page :onFetch='onFetch' :height='500' />
    </dt-modal-info>
    <assign-customer ref="assignCustomer"></assign-customer>
    <reassign ref="reassign" @regionSuccess="regionSuccess"></reassign>
  </div>
</template>

<script>
  import columnOpt from '../opt/columns.js'
  import customerMgr from '@/biz/customer/customer'
  import assignCustomer from './assignCustomer.vue'
  import reassign from './reassign.vue'
  export default {
    components: { assignCustomer, reassign },
    data() {
      return {
        columns: [],
        list: [],
        title: '分配记录',
        info: {},
      }
    },
    methods: {
      regionSuccess() {
        setTimeout(() => {
          this.$refs.table.fetch()
        }, 1000)
      },
      show() {
        this.$refs.info.show()
        this.columns = columnOpt.options(this, true)
        this.$refs.table.fetch()
      },
      hide() {
        this.$refs.table.clearFilter()
        this.$refs.info.hide()

      },
      onFetch(data) {
        console.log(data, '分配记录');
        return customerMgr.getDistributeLogPage({
          buildingId: this.$dt.buildInfo().housesId,
          ...data
        })
      },
      // 查看明细
      ViewDetails(val) {
        this.$refs.assignCustomer.show(val)
      },
      //校验重新分配的重新分配
      reassign(val) {
        console.log(val, '重新分配');
        let params = {
          oldUserId: val.oldUserId,
          newUserId: val.newUserId,
          createDate: val.createDate,
          buildingId: this.$dt.buildInfo().housesId,
        }
        customerMgr.checkDistributeList(params).then((res) => {
          console.log(res, '可分配的');
          this.$refs.reassign.show(res, val.newUserId)
        }).catch((err) => {
          console.log(err, '没有可分配的');
        });

      },
    },
  }
</script>
<style lang='scss' scoped>
  .check_process_detail {
    .detail_title {
      padding: 10px 0 20px 0;
      display: flex;

      &_label {
        width: 70px;
      }

      &_conent {
        flex: 1;
      }
    }

    .process_node {
      .title_text {
        font-size: 16px;
        line-height: 32px;
      }
    }

    .table_node {
      margin: 10px 0;
    }
  }
</style>